const koaRouter = require('koa-router');
const router = new koaRouter();
const jwtRouter = new koaRouter();

const router_list = require('./router');
const jwtRouter_list = require('./jwtRouter');
const paramValidator = require('../middleware/paramValidator');

router.prefix('/')
jwtRouter.prefix('/')

router_list.forEach(item => {
  const { method, path, controller, valid } = item;
  router[method](path, paramValidator(valid), controller);
});
jwtRouter_list.forEach(item => {
  const { method, path, controller, valid } = item;
  jwtRouter[method](path, paramValidator(valid), controller);
});

module.exports = {
  router,
  jwtRouter
};